-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Add documentation on top of rustc_middle/src/query/mod.rs
#142450
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
r? @SparrowLii rustbot has assigned @SparrowLii. Use |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job, thanks!
7b757e3
to
a7220f3
Compare
//! ## How to Read This Module | ||
//! | ||
//! Each `query` block in this file defines a single query, specifying its key and value types, along with various modifiers. | ||
//! These query definitions are processed by the macro system, which expands them into the necessary boilerplate code | ||
//! for the query system—including the [`Providers`] struct (a function table for all query implementations, where each field is | ||
//! a function pointer to the actual provider), caching, and dependency graph integration. | ||
//! **Note:** The `Providers` struct is not a Rust trait, but a struct generated by the macro system to hold all provider functions. | ||
//! The macro system also supports a set of **query modifiers** (see below) that control the behavior of each query. | ||
//! | ||
//! The actual provider functions are implemented in various modules and registered into the `Providers` struct | ||
//! during compiler initialization (see [`rustc_interface::passes::DEFAULT_QUERY_PROVIDERS`]). | ||
//! | ||
//! [`rustc_interface::passes::DEFAULT_QUERY_PROVIDERS`]: ../../rustc_interface/passes/static.DEFAULT_QUERY_PROVIDERS.html | ||
//! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I restructured it to focus on interpreting the code, focusing on the core structure of Providers, which is a good place to start in understanding this module.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rustc macros
is better than macro system
s here. Others looks fine.
The rustc-dev-guide subtree was changed. If this PR only touches the dev guide consider submitting a PR directly to rust-lang/rustc-dev-guide otherwise thank you for updating the dev guide with your changes. |
d1390f9
to
a7220f3
Compare
r=me after fixing the nits |
✌️ @xizheyin, you can now approve this pull request! If @SparrowLii told you to " |
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
a7220f3
to
ade2ad9
Compare
CI has passed. |
…wLii Add documentation on top of `rustc_middle/src/query/mod.rs` The `rustc-dev-guide` gives a high-level intro, but many details—especially about how the code works and modifiers in `query xxx(){...}`—are only in code comments or the macro implementation. This doc makes it easier for contributors and code readers to understand the workflow and available modifiers without jumping between files and docs. This PR adds a comprehensive module-level doc comment to `rustc_middle::query::mod.rs` that: 1. Provides an overview of the query system and macro-based query definitions for reading code more easily 2. Centralizes documentation for all query modifiers (previously scattered or only in `rustc_macro` code), closely following the authoritative list in QueryModifiers.
Rollup of 12 pull requests Successful merges: - #141639 (Expose discriminant values in stable_mir) - #142082 (Refactor `rustc_attr_data_structures` documentation) - #142125 (Stabilize "file_lock" feature) - #142236 (Add documentation for `PathBuf`'s `FromIterator` and `Extend` impls) - #142373 (Fix Debug for Location) - #142416 (Assorted bootstrap cleanups (step 2)) - #142431 (Add initial version of snapshot tests to bootstrap) - #142450 (Add documentation on top of `rustc_middle/src/query/mod.rs`) - #142528 (clarify `rustc_do_not_const_check` comment) - #142530 (use `if let` guards where possible) - #142561 (Remove an `njn:` comment accidentaly left behind.) - #142566 (Fix `-nopt` CI jobs) r? `@ghost` `@rustbot` modify labels: rollup
The
rustc-dev-guide
gives a high-level intro, but many details—especially about how the code works and modifiers inquery xxx(){...}
—are only in code comments or the macro implementation. This doc makes it easier for contributors and code readers to understand the workflow and available modifiers without jumping between files and docs.This PR adds a comprehensive module-level doc comment to
rustc_middle::query::mod.rs
that:rustc_macro
code), closely following the authoritative list in QueryModifiers.